package io.renren.modules.health.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.modules.health.dao.FoodPlanDetailDao;
import io.renren.modules.health.dto.FoodPlanDetailDTO;
import io.renren.modules.health.entity.FoodPlanDetailEntity;
import io.renren.modules.health.service.FoodPlanDetailService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * 计划详情
 *
 * @author Mark 
 * @since 1.0.0 2024-03-29
 */
@Service
public class FoodPlanDetailServiceImpl extends CrudServiceImpl<FoodPlanDetailDao, FoodPlanDetailEntity, FoodPlanDetailDTO> implements FoodPlanDetailService {
    @Override
    public QueryWrapper<FoodPlanDetailEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");
        Long foodPlanId = (Long)params.get("foodPlanId");
        List<Long> foodPlanIds = (List<Long>) params.get("foodPlanIds");

        QueryWrapper<FoodPlanDetailEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StrUtil.isNotBlank(id), "id", id);
        wrapper.eq(!Objects.isNull(foodPlanId), "food_plan_id", foodPlanId);
        wrapper.in(!Objects.isNull(foodPlanIds) && !foodPlanIds.isEmpty(), "food_plan_id", foodPlanIds);

        return wrapper;
    }
}